home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2003 December / The Sunday Times - The Month 2003-12.iso / pc / engine / shell / shell.swf / scripts / DefineSprite_106 / frame_1 / DoAction.as
Encoding:
Text File  |  2003-11-10  |  3.9 KB  |  203 lines

  1. function init()
  2. {
  3.    this.createEmptyMovieClip("mc_anim",Tardis.depth++);
  4.    restart();
  5. }
  6. function clearUp()
  7. {
  8.    mc_anim.unloadMovie();
  9.    delete onEnterFrame;
  10.    delete onAnimationEnd;
  11.    delete strLastSection;
  12. }
  13. function restart()
  14. {
  15.    Tardis.UsageData.addPageEntry(-1);
  16.    nmCurrent = -1;
  17.    next();
  18.    onAnimationEnd = function()
  19.    {
  20.       next();
  21.    };
  22.    startSoundLoop();
  23. }
  24. function pauseAt(section_name)
  25. {
  26.    if(section_name != strLastSection)
  27.    {
  28.       mc_anim.onLoad = function()
  29.       {
  30.          this.onLoad = null;
  31.          this.pause = true;
  32.       };
  33.       load(section_name);
  34.    }
  35.    else
  36.    {
  37.       mc_anim.pause = true;
  38.       mc_anim.gotoAndStop("still");
  39.    }
  40.    nmCurrent = Tardis.Sections.indexOf(section_name);
  41. }
  42. function playFrom(section_name)
  43. {
  44.    nmCurrent = -1;
  45.    mc_anim.onLoad = function()
  46.    {
  47.       this.onLoad = null;
  48.       this.entering = true;
  49.    };
  50.    load(section_name);
  51. }
  52. function playStart(section_name)
  53. {
  54.    mc_anim.onLoad = function()
  55.    {
  56.       this._parent.playStartWhenLoaded();
  57.       this.onLoad = null;
  58.    };
  59.    load(section_name);
  60. }
  61. function resume()
  62. {
  63.    mc_anim.play();
  64.    mc_anim.pause = false;
  65. }
  66. function restartSection()
  67. {
  68.    mc_anim.gotoAndPlay("start");
  69. }
  70. function interrupt()
  71. {
  72.    mc_anim.stop();
  73. }
  74. function hide()
  75. {
  76.    interrupt();
  77.    this._visible = false;
  78. }
  79. function show()
  80. {
  81.    mc_anim.play();
  82.    this._visible = true;
  83. }
  84. function load(section_name)
  85. {
  86.    mc_anim.loadMovie(Tardis.ASSETS_FOLDER + "splash/" + section_name + ".swf");
  87.    strLastSection = section_name;
  88. }
  89. function next()
  90. {
  91.    Tardis.bottomNav.splashOff(Tardis.Sections.item(nmCurrent).id);
  92.    nmCurrent++;
  93.    if(nmCurrent >= Tardis.Sections.length)
  94.    {
  95.       nmCurrent = 0;
  96.    }
  97.    var section_name = Tardis.Sections.item(nmCurrent).id;
  98.    if(section_name == null)
  99.    {
  100.       trace("splash : can\'t find index in Sections");
  101.    }
  102.    else
  103.    {
  104.       mc_anim.onLoad = function()
  105.       {
  106.          this._parent.playStartWhenLoaded();
  107.          this.onLoad = null;
  108.       };
  109.       load(section_name);
  110.       Tardis.bottomNav.splashOn(Tardis.Sections.item(nmCurrent).id);
  111.    }
  112. }
  113. function playStartWhenLoaded()
  114. {
  115.    mc_anim.onEnterFrame = function()
  116.    {
  117.       if(this.getBytesLoaded() == this.getBytesTotal())
  118.       {
  119.          this.gotoAndPlay("start");
  120.          this.onEnterFrame = null;
  121.       }
  122.    };
  123. }
  124. function __onAnimationEnd()
  125. {
  126.    onAnimationEnd();
  127. }
  128. function startSoundLoop()
  129. {
  130.    if(!Tardis.mc_snd_splash_loop)
  131.    {
  132.       Tardis.createEmptyMovieClip("mc_snd_splash_loop",-10);
  133.       Tardis.mc_snd_splash_loop.loadMovie(Tardis.ENGINE_FOLDER + "swf/bg_sound.swf");
  134.    }
  135.    else
  136.    {
  137.       fadeSoundLoop();
  138.    }
  139.    fadeSoundID = setInterval(monitorSoundLoop,40);
  140. }
  141. function monitorSoundLoop()
  142. {
  143.    mcSnd = Tardis.mc_snd_splash_loop;
  144.    if(mcSnd.getBytesLoaded() >= mcSnd.getBytesTotal() && mcSnd.getBytesTotal() > 4)
  145.    {
  146.       clearInterval(fadeSoundID);
  147.       fadeSoundLoop();
  148.    }
  149. }
  150. function fadeSoundLoop()
  151. {
  152.    if(mcSnd.active == true)
  153.    {
  154.       return undefined;
  155.    }
  156.    var sndLoop = mcSnd.snd = new Sound(mcSnd);
  157.    sndLoop.v = 0;
  158.    sndLoop.setVolume(0);
  159.    mcSnd.gotoAndStop("show");
  160.    mcSnd.active = true;
  161.    mcSnd.onEnterFrame = function()
  162.    {
  163.       with(this)
  164.       {
  165.          snd.v += 4;
  166.          if(snd.v <= 100)
  167.          {
  168.             snd.setVolume(snd.v);
  169.          }
  170.          else
  171.          {
  172.             onEnterFrame = null;
  173.          }
  174.       }
  175.    };
  176. }
  177. function endSoundLoop()
  178. {
  179.    if(mcSnd.active != true)
  180.    {
  181.       return undefined;
  182.    }
  183.    mcSnd.onEnterFrame = function()
  184.    {
  185.       with(this)
  186.       {
  187.          snd.v -= 8;
  188.          if(snd.v >= 0)
  189.          {
  190.             snd.setVolume(snd.v);
  191.          }
  192.          else
  193.          {
  194.             snd.stop();
  195.             delete snd;
  196.             gotoAndStop("hide");
  197.             active = false;
  198.             onEnterFrame = null;
  199.          }
  200.       }
  201.    };
  202. }
  203.